package com.smartstate.dataManagement.controller;

import com.smartstate.dataManagement.dto.EnergyDTO;
import com.smartstate.dataManagement.service.CarbonTraceService;
import com.smartstate.dataManagement.vo.PowerVo;
import com.smartstate.dataManagement.vo.ResultVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/CarbonTrace")
public class CarbonTraceController {

    @Resource
    private CarbonTraceService carbonTraceService;

    @PostMapping("queryCarbonTrace")
    public ResultVO queryCarbonTrace(@RequestBody EnergyDTO energyDTO){
        List<Map<String, Map<String, List<PowerVo>>>> list = carbonTraceService.queryCarbonTrace(energyDTO);
        if(list.size() > 0){
            return ResultVO.ok(list);
        }else {
            return ResultVO.fail();
        }
    }

}
